public class TestPerson {
    public static void main(String[] args) {
        Person p1 = new Person("mary",12);
        Person p2 = new Person("mary",12);
        System.out.println("结果是：" + p2.compareTo(p1));
    }
}
class Person{
    String name;
    int age;
    public Person(String name,int age){
        this.name = name;
        this.age = age;
    }
    public boolean compareTo(Person p){
        return this.name.equals(p.name) && this.age == p.age;
    }
}